package cn.quartz.dbquartz;

import org.quartz.JobExecutionContext;
import org.quartz.Trigger;
import org.quartz.TriggerListener;

/**
 * @author : zhuqiang
 * @version : V1.0
 * @date : 2016/9/17 14:08
 */
public class MyTriggerListener implements TriggerListener {

    @Override
    public String getName() {
        return "myTriggerListener";
    }

    @Override
    public void triggerFired(Trigger trigger, JobExecutionContext context) {
        System.out.println(" Trigger 被触发了，此时Job 上的 execute() 方法将要被执行.");
    }

    @Override
    public boolean vetoJobExecution(Trigger trigger, JobExecutionContext context) {
        System.out.println("发现此次Job的相关资源准备存在问题，不便展开任务，返回true表示否决此次任务执行");
        return false;
    }

    @Override
    public void triggerMisfired(Trigger trigger) {
        System.out.println( "当前Trigger触发错过了");
    }

    @Override//这是2.+版本的配置，差别在于将triggerInstructionCode从整型改成了枚举类型
    public void triggerComplete(Trigger trigger, JobExecutionContext context,
            Trigger.CompletedExecutionInstruction triggerInstructionCode) {
        System.out.println("Trigger 被触发并且完成了 Job 的执行,此方法被调用");
    }
}
